package com.kaka.bus.engine.result;

import android.content.Intent;
import android.support.v7.widget.AppCompatButton;
import android.support.v7.widget.Toolbar;
import android.widget.ImageView;
import android.widget.TextView;

import com.kaka.bus.R;
import com.kaka.bus.base.SimpleActivity;

import butterknife.BindView;

/**
 * Created by OnionMac on 2017/12/28.
 */

public class ResultActivity extends SimpleActivity {

    public static final int WAIT = 1; // 等待放款
    public static final int REPAY_SUCCESS = 2; // 还款成功
    public static final int WITHDRAW_SUCCESS = 3; // 充值成功
    public static final int MENBER = 4;//成为会员
    public static final int AUDIT = 5;//待审核
    public static final int PAY = 6;//支付中
    public static final int PAYFIAL = 7;//支付失败
    public static final int PERSON_CHECK = 8;//人工审核
    public static final int WAIT_LOAN = 9;//人工审核

    @BindView(R.id.toolbar_back)
    ImageView mToolbarBack;
    @BindView(R.id.toolbar_name)
    TextView mToolbarName;
    @BindView(R.id.toolbar)
    Toolbar mToolbar;
    @BindView(R.id.result_img)
    ImageView mResultImg;
    @BindView(R.id.result_text)
    TextView mResultText;
    @BindView(R.id.result_btn)
    AppCompatButton mResultBtn;

    private int mCurrentType = 0;
    public static final String RESULT_TYPE = "type";
    public static final String PROJECT_TYPE = "pro_type";
    private int proStatus;

    @Override
    protected void initView() {
        mToolbarBack.setOnClickListener(v -> finish());
    }

    @Override
    protected void initData() {
        Intent intent = getIntent();

        mCurrentType = intent.getIntExtra(RESULT_TYPE, 0);
        proStatus = intent.getIntExtra(PROJECT_TYPE, 0);
        switch (mCurrentType) {
            case PAY:
                /**
                 *  支付进行中...
                 */
                mToolbarName.setText("支付中");
                mResultText.setText("支付正在进行中,请等待");
                mResultImg.setImageResource(R.drawable.paysuccess);
                break;
            case AUDIT:
                mToolbarName.setText("审核中");
                mResultText.setText("您的订单正在火速审核中~");
                mResultImg.setImageResource(R.drawable.paysuccess);
                break;
            case PAYFIAL:
                mToolbarName.setText("支付失败");
                mResultText.setText("支付失败,请重新支付!");
                mResultImg.setImageResource(R.drawable.payfaild);
                break;
            case PERSON_CHECK:
                mToolbarName.setText("审核中");
                mResultText.setText("您的资料正在审核中~");
                mResultImg.setImageResource(R.drawable.paysuccess);
                break;
            case WAIT_LOAN:
                mToolbarName.setText("待放款");
                mResultText.setText("请您耐心等待放款，放款时间为工作日的9点~18点，实际到账时间会根据不同银行而有所差别");
                mResultImg.setImageResource(R.drawable.paysuccess);
                break;
            case REPAY_SUCCESS:
            case WITHDRAW_SUCCESS:
                mToolbarName.setText("支付成功");
                if (proStatus == 2) {
                    mResultText.setText("咨询服务费支付成功,请等待放卡!");
                } else {
                    mResultText.setText("咨询服务费支付成功,请等待放款!");
                }
                mResultImg.setImageResource(R.drawable.paysuccess);
                break;

        }

    }


    @Override
    protected void initListener() {
        super.initListener();
        mResultBtn.setOnClickListener(v -> {
            click();
        });

        mToolbarBack.setOnClickListener(v -> {
            click();
        });
    }

    private void click() {
        finish();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_result;
    }

    @Override
    protected boolean needFullScreen() {
        return true;
    }
}
